package com.ypc.user.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

import static com.ypc.user.config.ConfigParameter.redisip;
import static com.ypc.user.config.ConfigParameter.redisport;

@Configuration
public class RedisConfig {
    @Bean
    public JedisPool jedisPool(){
        JedisPool pool;
        JedisPoolConfig config=new JedisPoolConfig();
        String ip=redisip;
        int port=redisport;
        config.setMaxTotal(1000); //连接池最大有多少连接
        config.setMaxIdle(1000); //不繁忙时最多有多少个
        config.setMinIdle(1000); //不繁忙时最少有多少个
        pool= new JedisPool(config, ip, port);
        return pool;
    }
}
